<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use App\Model\UserModel;


class YjDay extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'yjday';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '加业绩天数';//够30天就清空业绩

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        //
        Log::info('自动打印');
        //判断是否够30天,够30天将天数和业绩归0
        $users = UserModel::get();
        foreach ($users as $k => $v){
            if($v->yj_day >= 30){
                UserModel::where('id',$v->id)->where('level','>',0)->update(['level'=>1,'yj_day'=>0,'person_yj'=>0,'team_yj'=>0]);
            }else{
                UserModel::where('id',$v->id)->where('level','>',0)->increment('yj_day',1);
            }
        }


    }
}
